package com.mycinema.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mycinema.biz.ShoppingCartBiz;
import com.mycinema.entity.Shoppingcart;

@Controller
public class ShoppingCartController {

	@Autowired
 private ShoppingCartBiz shoppingCartBiz;
	
	//添加购物车
	@RequestMapping("/addCart")
	public String addCart(int id,HttpSession session){
		Shoppingcart cart=(Shoppingcart) session.getAttribute("cart");
		if(cart==null){
			cart=new Shoppingcart();
			session.setAttribute("cart", cart);
		}
		shoppingCartBiz.addCart(cart, id);
		//返回显示购物车视图
		return "redirect:showCart";
	}
	
	@RequestMapping("showCart")
	public String showCart(){
		return "cart";
	}
}
